home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / basic / hi_gfa / source / hi_gfa.c next >
Encoding:
C/C++ Source or Header  |  1995-11-25  |  19.0 KB  |  683 lines

  1. #include <vdi.h>
  2. #include <aes.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <tos.h>
  6. #include <string.h>
  7. #include <process.h>
  8. #include <time.h>
  9. #include <ext.h>
  10. #include "hi_gfa_.h"
  11.  
  12. #define min(a, b)             ((a) < (b) ? (a) : (b))
  13. #define max(a, b)             ((a) > (b) ? (a) : (b))
  14.  
  15. typedef enum
  16. {
  17.     FALSE,
  18.     TRUE
  19. }
  20. boolean;
  21.  
  22. int work_in[12],work_out[57],pxyarray[8];
  23. int msg_buf[16];
  24. int handle,phys_handle;
  25.  
  26. int gl_hchar, gl_wchar, gl_hbox, gl_wbox;
  27. int gl_apid;    
  28.  
  29.  
  30. /* Window*/
  31. int wix,wiy,wiw,wih, wiwx,wiwy,wiwh,wiww ,w_handle;
  32. int wi2x,wi2y,wi2w,wi2h, wiw2x,wiw2y,wiw2h,wiw2w ,w_handle2;
  33.  
  34. /*resoure */
  35. OBJECT *dial;
  36. char    comp[256]="C:\\GFA_BCOMP.PRG", link[256]="C:\\GL.PRG",
  37.         inter[256]="C:\\GFABASIC.PRG", lib[256]="C:\\GFA3BLIB",
  38.         rcs[256]="C:\\RCS.PRG",
  39.         input[256]="C:\\TEST.GFA", object[256]="C:\\TEST.O", output[256]="C:\\TEST.PRG",
  40.         c_opt[26]="S& S< F<", l_opt[256]="-s";
  41. int   buttons[9]={AUSWAHL,COMPILE,LINK,CUNDL,INTER,RCS,TEST,SONST,ENDE};
  42. char     strings[8][20]={"Compiler","Linker","Interpreter","Library","RCS",
  43.                            "Input File","Object File","Output File"};
  44. int     pos,ob_ed=0;
  45.  
  46. /* Ausgabefenster */
  47. int char_height,lines;
  48. char msgs[10][80];
  49.  
  50. /* Execution */
  51. char com[256], link_opt[80], inter_cmd[256], rcs_cmd[256], env[256];
  52.  
  53. /* Funktionsprototypen */
  54. boolean open_vwork( void );
  55. void   close_vwork( void );
  56. void   gem_prg( void );
  57. int     get_char_height( void );   /* Textzeichenhöhe bestimmen */
  58. void      win1_update( void );         /* Fenster 1 wiederherstellen */        
  59. void     win2_update( void );         /* Fenster 2 wiederherstellen */
  60. void     white_box(int x, int y, int w, int h); /* weisses Rechteck zeichnen */
  61. long      my_clock( void );              /* Systemtimer */
  62. void   auswahl( void );              /* Input File auswählen */
  63. void      suchen( int num );              /* Compiler e.t.c finden */
  64. void     compiler( void );            /* Compiler aufrufen */
  65. void     linker( void );                 /* Linker aufrufen */
  66. void      interpreter( void );         /* Interpreter aufrufen */
  67. void      rcs_exec( void );             /* RCS ausführen */
  68. void      test_prog( void );              /* Compiliertes Programm testen */
  69. void   exec_other( void );             /* anderes Programm ausführen */
  70. void   msg_out( char *msg_text ); /* Texte in Fenster 2 ausgeben */
  71. void     rsrc_init( void );             /* rsc_file initialisieren */
  72. void   do_dial( void );                 /* Dialog managen */
  73.  
  74. boolean open_vwork( void )
  75. {
  76.    register int i;
  77.  
  78.    if (( gl_apid = appl_init() ) != -1 )
  79.    {
  80.       for ( i = 1; i < 10; work_in[i++] = 1 );
  81.       work_in[10] = 2;
  82.       phys_handle = graf_handle( &gl_wchar, &gl_hchar, &gl_wbox, &gl_hbox );
  83.       work_in[0]  = handle = phys_handle;
  84.  
  85.       v_opnvwk( work_in, &handle, work_out );
  86.  
  87.       return ( TRUE );
  88.    }
  89.    else
  90.       return ( FALSE );
  91. }
  92.  
  93. void close_vwork( void )
  94. {
  95.    v_clsvwk( handle );
  96.  
  97.    appl_exit( );
  98. }
  99.  
  100. int get_char_height( void ) /* Zeichenhöhe holen */
  101. {
  102.     int extend[8];
  103.     vqt_extent(handle,"M",extend);
  104.     return(extend[7]-extend[3]);
  105. }
  106.  
  107. long my_clock( void ) /*systemtimer */
  108. {
  109.     long *old_sp, clkticks, *clkptr;
  110.     
  111.     old_sp=(long *)Super(0L);
  112.     clkptr=(long *)0x4baL;
  113.     clkticks=*clkptr;
  114.     Super(old_sp);
  115.     return(clkticks);
  116. }
  117.  
  118. void win1_update( void )
  119. {
  120.     int r[4],clp[4];
  121.  
  122.     wind_update(BEG_UPDATE);
  123.     wind_get(w_handle,WF_FIRSTXYWH,&r[0],&r[1],&r[2],&r[3]);
  124.     clp[0]=r[0]; clp[1]=r[1];
  125.     clp[2]=r[0]+r[2]; clp[3]=r[1]+r[3];
  126.     vs_clip(handle,1,clp);
  127.     white_box(r[0],r[1],r[2],r[3]); 
  128.     objc_draw(dial,0,MAX_DEPTH,r[0],r[1],r[2],r[3]);
  129.     vs_clip(handle,0,clp);
  130.     do
  131.     {
  132.         wind_get(w_handle,WF_NEXTXYWH,&r[0],&r[1],&r[2],&r[3]);
  133.         if(r[2]!=0)
  134.         {
  135.             clp[0]=r[0]; clp[1]=r[1];
  136.             clp[2]=r[0]+r[2]; clp[3]=r[1]+r[3];
  137.             vs_clip(handle,1,clp);
  138.              white_box(r[0],r[1],r[2],r[3]);  
  139.             objc_draw(dial,0,MAX_DEPTH,r[0],r[1],r[2],r[3]);
  140.             vs_clip(handle,0,clp);
  141.         }
  142.     }while(r[2]!=0);
  143.     objc_edit(dial,S1+ob_ed,0,&pos,1);
  144.     wind_update(END_UPDATE);
  145. }
  146.  
  147. void win2_update( void )
  148. {
  149.     int i,r[4],clp[4];
  150.  
  151.     for(i=0;i<lines;i++) 
  152.         if(strlen(msgs[i])<79)
  153.             do{strcat(msgs[i]," ");} while(strlen(msgs[i])<79);
  154.     
  155.     wind_update(BEG_UPDATE);
  156.     wind_get(w_handle2,WF_FIRSTXYWH,&r[0],&r[1],&r[2],&r[3]);
  157.     clp[0]=r[0]; clp[1]=r[1];
  158.     clp[2]=r[0]+r[2]; clp[3]=r[1]+r[3];
  159.     vs_clip(handle,1,clp);
  160.     white_box(r[0],r[1],r[2],r[3]);
  161.     for(i=0;i<lines;i++) 
  162.         v_gtext(handle,wiw2x,wiw2y+(i+1)*char_height,msgs[i]);    
  163.     vs_clip(handle,0,clp);
  164.     do
  165.     {
  166.         wind_get(w_handle2,WF_NEXTXYWH,&r[0],&r[1],&r[2],&r[3]);
  167.         if(r[2]!=0)
  168.         {
  169.             clp[0]=r[0]; clp[1]=r[1];
  170.             clp[2]=r[0]+r[2]; clp[3]=r[1]+r[3];
  171.             vs_clip(handle,1,clp);
  172.              white_box(r[0],r[1],r[2],r[3]);
  173.              for(i=0;i<lines;i++) 
  174.                  v_gtext(handle,wiw2x,wiw2y+(i+1)*char_height,msgs[i]);    
  175.             vs_clip(handle,0,clp);
  176.         }
  177.     }while(r[2]!=0);
  178.     wind_update(END_UPDATE);
  179. }
  180.  
  181. void white_box(int x, int y, int w, int h) /* weisses Rechteck zeichnen */
  182. {
  183.     int pxy_array[8];
  184.     
  185.     vsf_interior(handle,FIS_SOLID);
  186.     vsf_color(handle,0);
  187.     vsf_perimeter(handle,0);
  188.     pxy_array[0]=x;   pxy_array[1]=y;
  189.     pxy_array[2]=x+w; pxy_array[3]=y+h;
  190.     v_bar(handle,pxy_array);
  191. }
  192.  
  193. void msg_out( char *msg_text) /* Texte in Fenster 2 ausgeben */
  194. {
  195.     int i;
  196.     
  197.     for(i=0;i<lines-1;i++) 
  198.         strcpy(msgs[i],msgs[i+1]);
  199.     strcpy(msgs[lines-1],msg_text);
  200.     win2_update();
  201. }
  202.     
  203. void save_settings( void ) /* Einstellungen Sichern */
  204. {
  205.     int i;
  206.     FILE *settings;
  207.     
  208.     settings = fopen("HI_GFA.INF","w");
  209.     if(settings!=NULL)
  210.     {
  211.         for(i=0; i<10; i++)
  212.             fprintf(settings,"%s\n",dial[S1+i].ob_spec.tedinfo->te_ptext);
  213.         fclose(settings);
  214.     }
  215. }
  216.  
  217. void auswahl( void ) /* Input File Auswählen */
  218. {
  219.     char path[110],name[15], *hptr;
  220.     int ex_bttn;
  221.  
  222.     msg_out("Input File wählen");
  223.     strcpy(path,dial[S1+5].ob_spec.tedinfo->te_ptext);
  224.     strcpy(name,strrchr(path,'\\')+1); 
  225.     strrchr(path,'\\')[1]='\0'; 
  226.     strcat(path,"*.GFA");
  227.     fsel_input(path,name,&ex_bttn);
  228.    msg_out(path); msg_out(name);
  229.     if(ex_bttn==1) /* OK Button */
  230.     {
  231.         hptr=strrchr(path,'\\'); hptr++; strcpy(hptr,name); /*Input name */
  232.         strcpy(dial[S1+5].ob_spec.tedinfo->te_ptext,path); 
  233.         strcpy(dial[S1+6].ob_spec.tedinfo->te_ptext,path); /*object name*/
  234.         hptr=strrchr(dial[S1+6].ob_spec.tedinfo->te_ptext,'.');
  235.         strcpy(hptr,".O");
  236.         strcpy(dial[S1+7].ob_spec.tedinfo->te_ptext,path); /*output_name */
  237.         hptr=strrchr(dial[S1+7].ob_spec.tedinfo->te_ptext,'.');
  238.         strcpy(hptr,".PRG");
  239.         save_settings();
  240.         win1_update();
  241.     }
  242. }   
  243.  
  244. void suchen(int num) /* Compiler e.t.c finden */
  245. {
  246.     char hint[80],path[110],name[15], *hptr;
  247.     int ex_bttn;
  248.  
  249.     strcpy(hint,"Searching for "); strcat(hint,strings[num]);
  250.     msg_out(hint);
  251.  
  252.     strcpy(path,dial[S1+num].ob_spec.tedinfo->te_ptext);
  253.     strcpy(name,strrchr(path,'\\')+1); 
  254.     strrchr(path,'\\')[1]='\0'; 
  255.     strcat(path,"*"); 
  256.     hptr=strrchr(name,'.');
  257.     hptr==NULL ? strcat(path,".*") : strcat(path,hptr);
  258.     fsel_input(path,name,&ex_bttn);
  259.    msg_out(path); msg_out(name);
  260.     if(ex_bttn==1) /* OK Button */
  261.     {
  262.         hptr=strrchr(path,'\\'); hptr++; strcpy(hptr,name); /*Programm name */
  263.         strcpy(dial[S1+num].ob_spec.tedinfo->te_ptext,path); 
  264.         win1_update();
  265.     }
  266. }
  267.  
  268. void get_com_env( void ) /* Command und environment Strings basteln */
  269. {
  270.     char *hptr;
  271.     
  272.     com[0]=' '; com[1]='\0';
  273.     strcat(com,dial[S1+5].ob_spec.tedinfo->te_ptext); /*inpath */
  274.     strcat(com," ");
  275.     strcat(com,dial[S1+8].ob_spec.tedinfo->te_ptext); /*comp options */
  276.     strcat(com," -O "); /* -o */
  277.     strcat(com,dial[S1+6].ob_spec.tedinfo->te_ptext); /*object file */
  278.     
  279.     strcpy(env,"G3OBJ=");
  280.     strcat(env,dial[S1+6].ob_spec.tedinfo->te_ptext); /*object file */
  281.     hptr=env+strlen(env)+1L;
  282.     strcpy(hptr,"G3PRG=");
  283.     strcat(hptr,dial[S1+7].ob_spec.tedinfo->te_ptext); /*out file */
  284.     hptr+=(strlen(hptr)+1L);
  285.     strcpy(hptr,"G3LIB=");
  286.     strcat(hptr,dial[S1+3].ob_spec.tedinfo->te_ptext); /* library */
  287.     strcpy(l_opt,"X");
  288.     strcpy(l_opt,dial[S1+9].ob_spec.tedinfo->te_ptext);/* Linker Options*/
  289.     strcpy(inter_cmd,"X");
  290.     strcpy(inter_cmd,dial[S1+5].ob_spec.tedinfo->te_ptext);/* Input File für den Interpreter */
  291.     strcpy(rcs_cmd,inter_cmd);
  292.     strcpy(strrchr(rcs_cmd,'.'),".RSC"); /*Commandline für das RCS */
  293. }
  294.  
  295. void compiler( void ) /* Compiler Starten */
  296. {
  297.     char hint[80];
  298.     int err,retcode,fi_handle,fi_dup,i;
  299.     FILE *tmp;
  300.     extern int errno;
  301.     long exe_time;
  302.     
  303.     msg_out("Starting compiler");
  304.     save_settings();
  305.     get_com_env();
  306.     exe_time=my_clock();
  307.     fi_handle=(int)Fcreate("HI_GFA.TMP",0);
  308.     fi_dup = (int)Fdup(1); 
  309.     Fforce(1,fi_handle);
  310.     err=exec(dial[S1].ob_spec.tedinfo->te_ptext, /*pfadname*/
  311.                 com,env,&retcode);
  312.     Fclose(fi_handle); Fforce(1,fi_dup);
  313.     tmp=fopen("HI_GFA.TMP","r");
  314.     while(feof(tmp)==0) 
  315.     {
  316.         i=0;
  317.         do{ hint[i]=getc(tmp); } while((hint[i++]!='\012')&&(feof(tmp)==0));
  318.         getc(tmp);
  319.         hint[i-1]='\0'; 
  320.         msg_out(hint);
  321.     }
  322.     unlink("HI_GFA.TMP");
  323.     if(err==0) errno=0;
  324.     sprintf(hint,"Fehler: %d -- Returnwert %d -- Zeit %5f",errno,retcode,(float)((my_clock()-exe_time)/200.0));
  325.     msg_out(hint);
  326. }
  327.  
  328. void linker( void ) /* Linker Starten */
  329. {
  330.     char hint[120];
  331.     int err,retcode,fi_handle,fi_dup,i;
  332.     FILE *tmp;
  333.     extern int errno;
  334.     long exe_time;
  335.     
  336.     msg_out("Starting linker");
  337.     save_settings();
  338.     get_com_env();
  339.     exe_time=my_clock();
  340.     fi_handle=(int)Fcreate("HI_GFA.TMP",0);
  341.     fi_dup = (int)Fdup(1); Fforce(1,fi_handle);
  342.     err=exec(dial[S1+1].ob_spec.tedinfo->te_ptext, /*pfadname*/
  343.                 link_opt,env,&retcode);
  344.     Fclose(fi_handle); Fforce(1,fi_dup);
  345.     tmp=fopen("HI_GFA.TMP","r");
  346.     while(feof(tmp)==0) 
  347.     {
  348.         i=0;
  349.         do{ hint[i]=getc(tmp); }  while((hint[i++]!='\012')&&(feof(tmp)==0));
  350.         getc(tmp);
  351.         hint[i-1]='\0'; 
  352.         msg_out(hint);
  353.     }
  354.     unlink("HI_GFA.TMP");
  355.     if(err==0) errno=0;
  356.     sprintf(hint,"Fehler: %d -- Returnwert %d -- Zeit %5f",errno,retcode,(my_clock()-exe_time)/200.0);
  357.     msg_out(hint);
  358.     sprintf(hint,"Killing %s",dial[S1+6].ob_spec.tedinfo->te_ptext);
  359.     msg_out(hint);
  360.     err=unlink(dial[S1+6].ob_spec.tedinfo->te_ptext);
  361.     (err==0) ? msg_out("done") : msg_out("failed");
  362. }
  363.  
  364. void interpreter( void ) /* Interpreter starten */
  365. {
  366.     char hint[80],path[110],old_path[110],name[15];
  367.     int retcode,err,old_drv;
  368.     extern int errno;
  369.     long exe_time;
  370.     
  371.     msg_out("Starting Interpreter");
  372.     save_settings();
  373.     get_com_env();
  374.     old_drv=getdisk();
  375.     getcurdir(0,old_path);
  376.     strcpy(path,dial[S1+5].ob_spec.tedinfo->te_ptext);
  377.     strcpy(name,strrchr(path,'\\')+1);
  378.     setdisk((int)(path[0]-'A')); 
  379.     *strrchr(path,'\\')='\0';
  380.     err=Dsetpath(path+2); 
  381.     exe_time=my_clock();
  382.     err=exec(dial[S1+2].ob_spec.tedinfo->te_ptext, /*pfadname*/
  383.                 name,"\0",&retcode);
  384.     if(err==0)errno=0;
  385.     sprintf(hint,"Fehler: %d -- Returnwert %d -- Zeit %5f",errno,retcode,(my_clock()-exe_time)/200.0);
  386.     setdisk(old_drv); Dsetpath(old_path);
  387.     wind_set(w_handle2,WF_TOP,0,0,0,0);
  388.     wind_set(w_handle,WF_TOP,0,0,0,0);
  389.     win1_update();
  390.     msg_out(hint);
  391. }
  392.  
  393. void rcs_exec( void ) /* RCS Starten */
  394. {
  395.     char hint[80],path[110],old_path[110],name[15];
  396.     int retcode,err,old_drv;
  397.     extern int errno;
  398.     long exe_time;
  399.     
  400.     msg_out("Starting Resource Construction Set");
  401.     get_com_env();
  402.     old_drv=getdisk();
  403.     getcurdir(0,old_path);
  404.     strcpy(path,dial[S1+4].ob_spec.tedinfo->te_ptext);
  405.     strcpy(name,strrchr(path,'\\')+1);
  406.     setdisk((int)(path[0]-'A')); 
  407.     *strrchr(path,'\\')='\0';
  408.     err=Dsetpath(path+2); 
  409.     exe_time=my_clock();
  410.     err=exec(name, /*pfadname*/
  411.                 rcs_cmd,"\0",&retcode);
  412.     if(err==0)errno=0;
  413.     sprintf(hint,"Fehler: %d -- Returnwert %d -- Zeit %5f",errno,retcode,(my_clock()-exe_time)/200.0);
  414.     setdisk(old_drv); Dsetpath(old_path);
  415.     wind_set(w_handle2,WF_TOP,0,0,0,0);
  416.     wind_set(w_handle,WF_TOP,0,0,0,0);
  417.     win1_update();
  418.     msg_out(hint);
  419. }
  420.  
  421. void test_prog( void ) /* Compiliertes Programm testen */
  422. {
  423.     char hint[80],path[110],old_path[106],name[15];
  424.     int retcode,err,old_drv;
  425.     extern int errno;
  426.     long exe_time;
  427.     
  428.     msg_out("Test");
  429.     save_settings();
  430.     old_drv=getdisk();
  431.     getcurdir(0,old_path);
  432.     strcpy(path,dial[S1+7].ob_spec.tedinfo->te_ptext);
  433.     strcpy(name,strrchr(path,'\\')+1);
  434.     setdisk((int)(path[0]-'A')); 
  435.     *strrchr(path,'\\')='\0';
  436.     err=Dsetpath(path+2); 
  437.     exe_time=my_clock();
  438.     err=exec(name, 
  439.                 "\0","\0",&retcode);
  440.     setdisk(old_drv); Dsetpath(old_path);
  441.     if(err==0)errno=0;
  442.     sprintf(hint,"Fehler: %d -- Returnwert %d -- Zeit %5f",errno,retcode,(my_clock()-exe_time)/200.0);
  443.     wind_set(w_handle2,WF_TOP,0,0,0,0);
  444.     wind_set(w_handle,WF_TOP,0,0,0,0);
  445.     win1_update();
  446.     msg_out(hint);
  447. }
  448.  
  449. void  exec_other( void )             /* anderes Programm ausführen */
  450. {
  451.     char hint[80],path[110],name[15], *hptr;
  452.     int ex_bttn,err,errno,retcode;
  453.     int old_drv;
  454.     char old_path[110];
  455.     long exe_time;
  456.     
  457.     msg_out("Executing other Program"); 
  458.     strcpy(path,"C:\\*.PRG"); strcpy(name,"\0");
  459.     fsel_input(path,name,&ex_bttn);
  460.    if(ex_bttn==1) /* OK Button */
  461.     {
  462.         old_drv=getdisk();
  463.         getcurdir(0,old_path);
  464.         setdisk((int)(path[0]-'A')); 
  465.         *strrchr(path,'\\')='\0';
  466.         err=Dsetpath(path+2); 
  467.         hptr=strrchr(path,'\\'); hptr++; strcpy(hptr,name); /*Programm name */
  468.         exe_time=my_clock();
  469.         err=exec(name, /*pfadname*/
  470.                 "\0","\0",&retcode);
  471.         if(err==0)errno=0;
  472.         sprintf(hint,"Fehler: %d -- Returnwert %d -- Zeit %5f",errno,retcode,(my_clock()-exe_time)/200.0);
  473.         setdisk(old_drv); Dsetpath(old_path);
  474.         wind_set(w_handle2,WF_TOP,0,0,0,0);
  475.         wind_set(w_handle,WF_TOP,0,0,0,0);
  476.         win1_update();
  477.         msg_out(hint);
  478.     }
  479. }
  480.  
  481. void rsrc_init( void ) /* Strings in rsc eintragen und Fenstergröße bestimmen */
  482. {
  483.     FILE *settings;
  484.     int y_dial, dummx,dummw,dummh;
  485.  
  486.     wind_get(0,WF_WORKXYWH,&dummx,&y_dial,&dummw,&dummh);
  487.     wind_calc(WC_WORK,NAME|MOVER,dummx,y_dial,dummw,dummh,&dummx,&y_dial,&dummw,&dummh);
  488.     if(!rsrc_load("hi_gfa.rsc"))
  489.     {
  490.         form_alert(1,"[1][RSC-Datei nicht gefunden][Ach so]");
  491.         exit(0);
  492.     }
  493.     rsrc_gaddr(ROOT,DIA0,(void *)&dial);
  494.     form_center(dial,&wiwx,&wiwy,&wiww,&wiwh);
  495.     wiwy=dial[0].ob_y=y_dial;
  496.     settings = fopen("HI_GFA.INF","r");
  497.     if (settings!=NULL) /*inf Datei lesen*/
  498.     {
  499.         fscanf(settings,"%s",comp);
  500.         fscanf(settings,"%s",link);
  501.         fscanf(settings,"%s",inter);
  502.         fscanf(settings,"%s",lib);
  503.         fscanf(settings,"%s",rcs);
  504.         fscanf(settings,"%s",input);
  505.         fscanf(settings,"%s",object);
  506.         fscanf(settings,"%s",output);
  507.         fscanf(settings,"%s",c_opt);
  508.         fscanf(settings,"%s",l_opt);
  509.         fclose(settings);
  510.     }
  511.     strcpy(dial[S1].ob_spec.tedinfo->te_ptext, comp);/* String eintragen */
  512.     strcpy(dial[S1+1].ob_spec.tedinfo->te_ptext, link);/* String eintragen */
  513.     strcpy(dial[S1+2].ob_spec.tedinfo->te_ptext, inter);/* String eintragen */
  514.     strcpy(dial[S1+3].ob_spec.tedinfo->te_ptext, lib);/* String eintragen */
  515.     strcpy(dial[S1+4].ob_spec.tedinfo->te_ptext, rcs);/* String eintragen */            
  516.     strcpy(dial[S1+5].ob_spec.tedinfo->te_ptext, input);/* String eintragen */
  517.     strcpy(dial[S1+6].ob_spec.tedinfo->te_ptext, object);/* String eintragen */    
  518.     strcpy(dial[S1+7].ob_spec.tedinfo->te_ptext, output);/* String eintragen */    
  519.     strcpy(dial[S1+8].ob_spec.tedinfo->te_ptext, c_opt);/* String eintragen */    
  520.     strcpy(dial[S1+9].ob_spec.tedinfo->te_ptext, l_opt);/* String eintragen */    
  521.  
  522. }
  523.  
  524. void do_dial() /* Hauptdialog */
  525. {
  526.     int what,mousex,mousey,mbutton,mstate,key,klicks;
  527.     int i, key0, sel, knopf;
  528.         
  529.     do
  530.     {
  531.         knopf=-1;
  532.         what= evnt_multi(MU_KEYBD|MU_BUTTON|MU_MESAG,
  533.                             1,1,1,
  534.                             1,wiwx,wiwy,wiww,wiwh,
  535.                             0,0,0,0,0,
  536.                            msg_buf,0,0,
  537.                              &mousex,&mousey,&mbutton,&mstate,&key,&klicks);
  538.         switch(what)
  539.         {
  540.             case MU_KEYBD:        /* Keyboard Event */
  541.                 key0=key; key>>=8;  /* nur Ascii interessant */
  542.                 if(key>=59 && key<=67) knopf=key-59;    /*Funktion Key*/
  543.                 else
  544.                 {
  545.                     switch(key)
  546.                     {
  547.                         case 72:    /*CUR UP*/
  548.                             objc_edit(dial,S1+ob_ed,0,&pos,3);
  549.                             ob_ed--; if(ob_ed==-1)ob_ed=9;
  550.                             objc_edit(dial,S1+ob_ed,0,&pos,1);
  551.                             break;
  552.                         case 80:    /*CUR DN */
  553.                             objc_edit(dial,S1+ob_ed,0,&pos,3);
  554.                             ob_ed=(ob_ed+1) % 10;
  555.                             objc_edit(dial,S1+ob_ed,0,&pos,1);
  556.                             break;
  557.                         default:
  558.                             objc_edit(dial,S1+ob_ed,key0,&pos,2);
  559.                     }
  560.                 } break;
  561.             case MU_BUTTON:
  562.                 sel=objc_find(dial,ROOT,MAX_DEPTH,mousex,mousey);
  563.                 if(mstate==0)             /* Einfachklick */
  564.                 {
  565.                     for(i=0; i<9;i++)    /* Buttons */
  566.                         {if(sel==buttons[i]) knopf=i;}
  567.                     for(i=0; i<10;i++) /*Strings */
  568.                         if(sel==S1+i)      /*Objc_edit ändern */
  569.                         {
  570.                         objc_edit(dial,S1+ob_ed,0,&pos,3);
  571.                         ob_ed=sel-S1;
  572.                         objc_edit(dial,S1+ob_ed,0,&pos,1);
  573.                         }
  574.                 }
  575.                 else
  576.                 {
  577.                     for(i=0; i<8;i++) /*Strings */
  578.                         if(sel==S1+i)      /*Entspr. Objekt suchen*/
  579.                         {
  580.                         /* Falls i=5 -> Auswahl, sonst normal suchen */
  581.                         (i==5) ? knopf=0 : suchen(i);
  582.                         }
  583.                 }    
  584.                 break;
  585.             case MU_MESAG: 
  586.                 switch(msg_buf[0])
  587.                 {
  588.                     case WM_REDRAW:
  589.                     if(msg_buf[3]==w_handle2) win2_update();
  590.                     else
  591.                     {
  592.                         win1_update();
  593.                     }break;
  594.                     case WM_MOVED:
  595.                     if(msg_buf[3]==w_handle2)
  596.                     {
  597.                         wi2x=msg_buf[4]; wi2y=msg_buf[5];
  598.                         wi2w=msg_buf[6]; wi2h=msg_buf[7];
  599.                         wind_calc(NAME|MOVER,WC_WORK,
  600.                                      wi2x,wi2y,wi2w,wi2h,&wiw2x,&wiw2y,&wiw2w,&wiw2h);
  601.                         wind_set(w_handle2,WF_CURRXYWH,wi2x,wi2y,wi2w,wi2h);
  602.                         win2_update();
  603.                     }
  604.                     else
  605.                     {
  606.                         wix=msg_buf[4]; wiy=msg_buf[5];
  607.                         wiw=msg_buf[6]; wih=msg_buf[7];
  608.                         wind_calc(NAME|MOVER,WC_WORK,
  609.                                      wix,wiy,wiw,wih,&wiwx,&wiwy,&wiww,&wiwh);
  610.                         dial[0].ob_x=wiwx; dial[0].ob_y=wiwy;
  611.                         wind_set(w_handle,WF_CURRXYWH,wix,wiy,wiw,wih);
  612.                         win1_update();
  613.                     }
  614.                     break;
  615.                 }    
  616.         }
  617.         switch(knopf)
  618.         {
  619.             case 0:    auswahl(); break;
  620.             case 1:     compiler(); break;
  621.             case 2:    linker(); break;
  622.             case 3:    compiler(); linker(); break;
  623.             case 4:     interpreter(); break;
  624.             case 5:    rcs_exec(); break;
  625.             case 6:    test_prog(); break;
  626.             case 7:    exec_other(); break;
  627.         }
  628.     }while(knopf!=8);
  629.     save_settings();
  630. }                  
  631.  
  632. void gem_prg() /* Fenster einrichten und dann dial aufrufen */
  633. {
  634.     void *dummy;
  635.     
  636.     dummy=0;    /* gibt sonst Warning*/
  637.     graf_mouse(M_OFF,(void *)dummy);
  638.     rsrc_init();
  639.     char_height=get_char_height();
  640.     /*Dialog Fenster*/
  641.     wind_update(BEG_UPDATE);
  642.     wind_calc(WC_BORDER,NAME|MOVER,wiwx,wiwy,wiww,wiwh,&wix,&wiy,&wiw,&wih);
  643.     w_handle=wind_create(NAME|MOVER,wix,wiy,wiw,wih);
  644.     wind_set(w_handle,WF_NAME,"HI-Gfa",0,0);
  645.     wind_open(w_handle,wix,wiy,wiw,wih);
  646.     /*Ausgabe Fenster*/
  647.     wind_calc(WC_WORK,NAME|MOVER,0,wiy+wih+10,min(work_out[0],640),min(11*char_height,work_out[1]-10-wiy-wih),
  648.                  &wiw2x,&wiw2y,&wiw2w,&wiw2h);
  649.     wind_calc(WC_BORDER,NAME|MOVER,wiw2x,wiw2y,wiw2w,wiw2h,
  650.                  &wi2x,&wi2y,&wi2w,&wi2h);
  651.     lines=wiw2h/char_height;
  652.     w_handle2=wind_create(NAME|MOVER,wi2x,wi2y,wi2h,wi2w);
  653.     wind_set(w_handle2,WF_NAME,"What's loose",0,0);
  654.     wind_open(w_handle2,wi2x,wi2y,wi2w,wi2h);
  655.     vsf_interior(handle,1); vsf_color(handle,0); 
  656.     pxyarray[0]=wiw2x;pxyarray[1]=wiw2y;pxyarray[2]=wiw2x+wiw2w;pxyarray[3]=wiw2y+wiw2h;
  657.     v_bar(handle, pxyarray );
  658.     wind_set(w_handle,WF_TOP,0,0,0);
  659.     wind_update(END_UPDATE);
  660.     win1_update();
  661.     graf_mouse(M_ON,dummy); graf_mouse(ARROW,dummy);
  662.     do_dial();
  663. }
  664.  
  665. void main( void ) /* GEM init */
  666. {
  667.    if ( open_vwork( ) == TRUE )
  668.    {
  669.       gem_prg( );
  670.       /* Aufräumen */
  671.       wind_close(w_handle2); wind_delete(w_handle2);
  672.       wind_close(w_handle);  wind_delete(w_handle);
  673.       rsrc_free();
  674.       close_vwork( );
  675.       exit ( 0 );
  676.    }
  677.    else
  678.    {
  679.       fprintf( stderr, "Fehler bei der Programminitialisierung!" );
  680.       exit ( -1 );
  681.    }
  682. }
  683.